home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2004 August / My Disc.iso / games / demo / Rapid gunner / RG_Setup.exe / common / diffusemap.fx < prev    next >
Encoding:
Text File  |  2004-04-19  |  4.2 KB  |  152 lines

  1. // LF2 Engine
  2. // (C) 2002-3 7FX
  3. //---------------------------------------------------------------------------
  4. #include "common.fxh"
  5. //---------------------------------------------------------------------------
  6. // Common parameters
  7. // Desc
  8. string desc : Description = "Mapuje difuzni texturu na mesh.";
  9. // Requirements
  10. string req : Requirements = "Diffusemap";
  11. // vertex format
  12. string vf : VertexFormat = "POSITION | DIFFUSEMAP"; // 65 (for export) 
  13. //---------------------------------------------------------------------------
  14. // Used constants
  15. const matrix cMtxWVP : WorldViewProjection;
  16. const int cAlphaRef : AlphaRef = 0;
  17. // Diffuse color, default white
  18. const float4 cDiffuse : Diffuse = {1.f, 1.f, 1.f, 1.f};
  19. // CullMode - NONE=1, CW=2, CCW=3
  20. const int cCullMode : CullMode = 3; // default CCW
  21. // Matrices for fixed function technique
  22. const matrix cMtxW : World;
  23. // Sampler filters
  24. DECLARE_TEX_SAMPLER_VALUES;
  25. //---------------------------------------------------------------------------
  26. // Diffuse map effect 
  27. texture2D diffusemap : DiffuseMap;
  28. //---------------------------------------------------------------------------
  29. // Diffuse map sampler
  30. sampler diffusemap_sampler = sampler_state
  31. {
  32.     Texture = <diffusemap>;
  33.     SET_TEX_SAMPLER_VALUES;
  34. };
  35. //---------------------------------------------------------------------------
  36. // programs
  37. struct VS_OUTPUT
  38. {
  39.     float4 Position : POSITION;
  40.     float2 DiffuseMapCoord : TEXCOORD0;
  41. };
  42.  
  43. // vertex shader
  44. VS_OUTPUT VS(float4 Position : POSITION, float2 DiffuseMapCoord : TEXCOORD0)
  45. {
  46.     VS_OUTPUT Out = (VS_OUTPUT)0;
  47.     Out.Position = mul(Position, cMtxWVP);
  48.     Out.DiffuseMapCoord = DiffuseMapCoord;
  49.     return Out;
  50. }
  51.  
  52. // pixel shader
  53. float4 PS(VS_OUTPUT In) : COLOR
  54. {
  55.     return cDiffuse * tex2D(diffusemap_sampler, In.DiffuseMapCoord);
  56. }
  57.  
  58. //---------------------------------------------------------------------------
  59. // Technique with vertex and pixel shader
  60. technique vs11_ps11
  61. <
  62.     // streams for technique
  63.     string stream1 = "POSITION | DIFFUSEMAP";
  64.     //string stream2 = "POSITION";
  65.     //string stream3 = "DIFFUSEMAP";
  66. >
  67. {
  68.     pass p0
  69.     <
  70.         // stream mapping
  71.         string streammap = "stream1";
  72.         //string streammap = "stream2 | stream3";
  73.     >
  74.     {
  75.         AlphaRef = <cAlphaRef>;
  76.         CullMode = <cCullMode>;
  77.     
  78.         VertexShader = compile vs_1_1 VS();
  79.         PixelShader  = compile ps_1_1 PS();
  80.     }
  81. }
  82. //---------------------------------------------------------------------------
  83. // Basic technique - vertex shader, no pixel shader
  84. technique vs11_ps0
  85. <
  86.     // streams for technique
  87.     string stream1 = "POSITION | DIFFUSEMAP";
  88.     //string stream2 = "POSITION";
  89.     //string stream3 = "DIFFUSEMAP";
  90. >
  91. {
  92.     pass p0
  93.     <
  94.         // stream mapping
  95.         string streammap = "stream1";
  96.         //string streammap = "stream2 | stream3";
  97.     >
  98.     {
  99.         AlphaRef = <cAlphaRef>;
  100.            CullMode = <cCullMode>;
  101.         TextureFactor = <cDiffuse>;
  102.    
  103.         VertexShader = compile vs_1_1 VS();
  104.         
  105.         Sampler[0] = <diffusemap_sampler>;
  106.         ColorOp[0] = Modulate;
  107.         ColorArg1[0] = TFactor;
  108.         ColorArg2[0] = Texture;
  109.         AlphaOp[0] = Modulate;
  110.         AlphaArg1[0] = TFactor;
  111.         AlphaArg2[0] = Texture;
  112.     }
  113. }
  114. //---------------------------------------------------------------------------
  115. // Basic technique - fixed function
  116. technique vs0_ps0
  117. <
  118.     // streams for technique
  119.     string stream1 = "POSITION | DIFFUSEMAP";
  120.     //string stream2 = "POSITION";
  121.     //string stream3 = "DIFFUSEMAP";
  122. >
  123. {
  124.     pass p0
  125.     <
  126.         // stream mapping
  127.         string streammap = "stream1";
  128.         //string streammap = "stream2 | stream3";
  129.     >
  130.     {
  131.         // matrices
  132.         WorldTransform[0] = <cMtxW>;
  133.     
  134.         AlphaRef = <cAlphaRef>;
  135.            CullMode = <cCullMode>;
  136.         TextureFactor = <cDiffuse>;
  137.     
  138.         Sampler[0] = <diffusemap_sampler>;
  139.         ColorOp[0] = Modulate;
  140.         ColorArg1[0] = TFactor;
  141.         ColorArg2[0] = Texture;
  142.         AlphaOp[0] = Modulate;
  143.         AlphaArg1[0] = TFactor;
  144.         AlphaArg2[0] = Texture;
  145.     }
  146. }
  147. //---------------------------------------------------------------------------
  148.  
  149.  
  150.  
  151.  
  152.